/**
 * 
 */

package com.shy.portal.entity;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.google.gson.annotations.Expose;
import com.shy.base.entity.BaseEntity;

/**
 * <p>
 * Title: menu
 * </p>
 * <p>
 * Description:菜单實体类
 * </p>
 * <p>
 * Company:
 * </p>
 * 
 * @author H2013788
 */
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Entity
@Table(name = "portal_menu")
public class Menu extends BaseEntity{
    private static final long serialVersionUID = 1L;

    /**
     * 父级菜单ID
     */
    @Expose
    @ManyToOne
    @JoinColumn(name = "parent_id")
    private Menu parent;

    /**
     * 菜单名
     */
    @Expose
    @Column(name = "menu_name")
    private String menuName;

    /**
     * 菜单代码
     */
    @Expose
    @Column(name = "menu_code")
    private String menuCode;

    /**
     * 菜单URL
     */
    @Expose
    @Column(name = "menu_url")
    private String menuUrl;

    
    @OneToMany(cascade = CascadeType.REMOVE, fetch = FetchType.LAZY, orphanRemoval = true)
    @JoinColumn(name = "menu_id", referencedColumnName="id")
    private Set<RoleMenu> roleMenus;
    
    
    @OneToMany(cascade = CascadeType.REMOVE, fetch = FetchType.LAZY, orphanRemoval = true)
    @JoinColumn(name = "parent_id", referencedColumnName="id")
    private Set<Menu> childrens;
    
    @OneToMany(cascade = CascadeType.REMOVE, fetch = FetchType.LAZY, orphanRemoval = true)
    @JoinColumn(name = "menu_id", referencedColumnName="id")
    private Set<Permission> permissions;
    

    /**
     * 描述
     */
    @Column(name = "description")
    private String description;

    /**
     * 级別
     */
    @Expose
    @Column(name = "menu_level")
    private Integer level;

    /**
     * sort
     */
    @Expose
    @Column(name = "sort")
    private Integer sort;


    /**
     * @return the parent
     */
    public Menu getParent() {
        return parent;
    }

    /**
     * @param parent
     *            the parent to set
     */
    public void setParent(Menu parent) {
        this.parent = parent;
    }

    /**
     * @return the menuName
     */
    public String getMenuName() {
        return menuName;
    }

    /**
     * @param menuName
     *            the menuName to set
     */
    public void setMenuName(String menuName) {
        this.menuName = menuName;
    }

    /**
     * @return the menuCode
     */
    public String getMenuCode() {
        return menuCode;
    }

    /**
     * @param menuCode
     *            the menuCode to set
     */
    public void setMenuCode(String menuCode) {
        this.menuCode = menuCode;
    }

    /**
     * @return the menuUrl
     */
    public String getMenuUrl() {
        return menuUrl;
    }

    /**
     * @param menuUrl
     *            the menuUrl to set
     */
    public void setMenuUrl(String menuUrl) {
        this.menuUrl = menuUrl;
    }


    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @param description
     *            the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @return the level
     */
    public Integer getLevel() {
        return level;
    }

    /**
     * @param level
     *            the level to set
     */
    public void setLevel(Integer level) {
        this.level = level;
    }

    /**
     * @return the sort
     */
    public Integer getSort() {
        return sort;
    }

    /**
     * @param sort
     *            the sort to set
     */
    public void setSort(Integer sort) {
        this.sort = sort;
    }

    public Set<RoleMenu> getRoleMenus() {
        return roleMenus;
    }

    public void setRoleMenus(Set<RoleMenu> roleMenus) {
        this.roleMenus = roleMenus;
    }

    public Set<Menu> getChildrens() {
        return childrens;
    }

    public void setChildrens(Set<Menu> childrens) {
        this.childrens = childrens;
    }

    public Set<Permission> getPermissions() {
        return permissions;
    }

    public void setPermissions(Set<Permission> permissions) {
        this.permissions = permissions;
    }
    

}
